// void, Obj This

Unit  this;
point pt;
int r;

this = This.AsUnit();
// no sleep
if (.IsValid){// leave parry mode at new command
	.SetParryMode(false);
	
	if(.IsMilitary)
		if(.speed_factor < 100)
			.SetSpeedFactor(100);

	//if(.hero.command != "stand_position" && .hero.command != "idle")
		//Sleep(rand(200)+10);
	
	if(.item_count > 0){
		Item item;
		
		item = .FindItem("Terrain bonus I");
		if(item.IsValid)
			.RemoveItemsOfType("Terrain bonus I");
		else {
			item = .FindItem("Terrain bonus II");
			if(item.IsValid)
				.RemoveItemsOfType("Terrain bonus II");
			else {
				item = .FindItem("Terrain bonus III");
				if(item.IsValid)
					.RemoveItemsOfType("Terrain bonus III");
				else {
					item = .FindItem("Terrain bonus IV");
					if(item.IsValid)
						.RemoveItemsOfType("Terrain bonus IV");
				}
			}
		}
	}
	
	.FormAcceptMove();
	r = rand(1000);
	while(.HasPath()){
		.FormKeepMoving(1000+r);
	}

	if(.hero.IsValid){
	   
		pt = .hero.GetFinalPartyOrientation() - Point(1024, 1024);
		
		if(pt.x == 0 && pt.y == 0)
			pt = .hero.GetDir();
			
		.Face(.pos + pt);

		Sleep(rand(100)+50);
		.SetCommand("stand_position");
	}
}

